package com.itboye.hutouben.responsitory;

import com.google.gson.reflect.TypeToken;
import com.itboye.hutouben.bean.HomeMallBean;
import com.itboye.hutouben.bean.MoneyShengyuBean;
import com.itboye.hutouben.bean.ShopIngMallBean;
import com.itboye.hutouben.interfaces.IShopIngMallInterface;
import com.itboye.hutouben.volley.BaseErrorListener;
import com.itboye.hutouben.volley.BaseNetRepository;
import com.itboye.hutouben.volley.BaseSuccessReqListener;
import com.itboye.hutouben.volley.ByJsonRequest;
import com.itboye.hutouben.volley.ICompleteListener;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by itboye on 2016/12/5.
 */

public class ShopIngMallprinsitory extends BaseNetRepository implements IShopIngMallInterface<String> {
    public static final String APIKEY = "100";
    public static final String DieseOil = "";//
    public static  final String TyPe="";//轮胎
    public static  final String Valve="";//阀门
    public static  final String AutoParts="";//汽配
    public static  final String VehicleUrea="";//车用尿素
    public static  final String Tixian="By_Wallet_apply";//提现
    public static  final String Yuee="By_Wallet_detail";//余额查询

    public ShopIngMallprinsitory(ICompleteListener iCompleteListener) {
    }

    @Override
    public void onShopIngMallDieselOil(String uid, String id) {
        Type Type = new TypeToken<ShopIngMallBean>() {

        }.getType();
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);

        (new ByJsonRequest.Builder<ShopIngMallBean>())
                .setTypeVerParamsAndReturnClass(APIKEY, DieseOil, map, Type)
                .requestListener(
                        new BaseSuccessReqListener<ShopIngMallBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();

    }



    @Override
    public void onShopIngMallTyRe(String uid, String id) {
        Type Type = new TypeToken<ShopIngMallBean>() {

        }.getType();
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);

        (new ByJsonRequest.Builder<ShopIngMallBean>())
                .setTypeVerParamsAndReturnClass(APIKEY, TyPe, map, Type)
                .requestListener(
                        new BaseSuccessReqListener<ShopIngMallBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 汽配
     * @param uid
     * @param id
     */
    @Override
    public void onShopIngMllValve(String uid, String id) {
        Type Type = new TypeToken<ShopIngMallBean>() {

        }.getType();
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);

        (new ByJsonRequest.Builder<ShopIngMallBean>())
                .setTypeVerParamsAndReturnClass(APIKEY, Valve, map, Type)
                .requestListener(
                        new BaseSuccessReqListener<ShopIngMallBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onShopIngAutoParts(String uid, String id) {
        Type Type = new TypeToken<ShopIngMallBean>() {

        }.getType();
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);

        (new ByJsonRequest.Builder<ShopIngMallBean>())
                .setTypeVerParamsAndReturnClass(APIKEY, AutoParts, map, Type)
                .requestListener(
                        new BaseSuccessReqListener<ShopIngMallBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 车用尿素
     * @param uid
     * @param id
     */
    @Override
    public void onShopIngVehicleUrea(String uid, String id) {
        Type Type = new TypeToken<ShopIngMallBean>() {

        }.getType();
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);

        (new ByJsonRequest.Builder<ShopIngMallBean>())
                .setTypeVerParamsAndReturnClass(APIKEY, VehicleUrea, map, Type)
                .requestListener(
                        new BaseSuccessReqListener<ShopIngMallBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onMoney(String uid, String money, String account_id) {
        Type Type = new TypeToken<String>() {

        }.getType();
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("money", money);
        map.put("account_id",account_id);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(APIKEY,Tixian, map, Type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onMoneyYue(String uid) {
        Type Type = new TypeToken<MoneyShengyuBean>() {

        }.getType();
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        (new ByJsonRequest.Builder<MoneyShengyuBean>())
                .setTypeVerParamsAndReturnClass(APIKEY,Yuee, map, Type)
                .requestListener(
                        new BaseSuccessReqListener<MoneyShengyuBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
}
